package com.tao.mytestgreendao

import android.content.Context
import com.github.yuweiguocn.library.greendao.MigrationHelper
import com.tao.basegreendaomanager.BaseGreendaoManager
import com.tao.basegreendaomanager.BaseGreendaoManager1
import com.tao.mytestgreendao.gen.*
import org.greenrobot.greendao.database.Database
import org.greenrobot.greendao.query.QueryBuilder

/**
 *reate by tao on{DATE}
 */
class MyDaoManager : BaseGreendaoManager<DaoMaster, DaoSession, MyGreenDaoDevHelper>() {
    companion object {
        @JvmStatic
        @get:Synchronized
        var daoManager = MyDaoManager()
    }
 
    init {
        MigrationHelper.DEBUG =true
        QueryBuilder.LOG_SQL=true
        QueryBuilder.LOG_VALUES=true
        
    }

     override fun myGreenDaoDevHelper(
        dbName: String,
        classs: Array<Class<*>>
    ): MyGreenDaoDevHelper {
        return MyGreenDaoDevHelper(context, dbName, classs)
    }



    fun init(context: Context) {
        val configArray = arrayOf(
            DbConfig(
                DBNames.userDbName,
                arrayOf(UserEntityDao::class.java, TeacherEntityDao::class.java,FundsinfoBeanDao::class.java)
            )
        )
        initGreendao(context.applicationContext, configArray)
    }


    fun getUserDao(): UserEntityDao? {
        return getDaoSession(DBNames.userDbName)?.userEntityDao
    }
    fun getFundsInfoDao(): FundsinfoBeanDao? {
       return getDaoSession(DBNames.userDbName)?.fundsinfoBeanDao
    }

    override fun daoMaster(dbName: String, database: Database): DaoMaster {

        return DaoMaster(database)
    }
}